/**   
 * Copyright © 2019 eSunny Info. Tech Ltd. All rights reserved.
 * 
 * @Description:TODO(功能)
 * @className DBHelper.java
 * @Package: com.erp.util 
 * @author: yj   
 * @date: 2019年1月16日 下午3:16:26 
 */
package com.erp.util;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.ResourceBundle;

import com.alibaba.druid.pool.DruidDataSource;

/**
 * @className DBHelper.java
 * @author yj
 * @Description:TODO(功能)
 * @Date 2019年1月16日
 */
public class DBHelper {
	
	private static String driver;
	private static String url;
	private static String user;
	private static String password;
	private static DruidDataSource source;
	static {
		// 引入db配置文件,拿到数据库连接信息
		ResourceBundle bundle = ResourceBundle.getBundle("db");
		driver = bundle.getString("driver");
		url = bundle.getString("url");
		user = bundle.getString("user");
		password = bundle.getString("password");
		
		// 使用alibaba 数据库连接池 
		source = new DruidDataSource();
		source.setDriverClassName(driver);
		source.setUrl(url);
		source.setUsername(user);
		source.setPassword(password);
	}
	
	// 获取 conn 连接
	public static Connection getConnection() throws SQLException {
		return source.getConnection();
	}
	

}
